<?php

require_once("configure.php");

$user = $_POST["user"];
$pwd = $_POST["pwd"];

$MySqlLinkId = mysql_connect(DBHost, DBUser, DBPwd);
if($MySqlLinkId == FALSE)
{
	echo("({ErrCode:1, ErrMsg:'链接数据库失败！'})");
	exit();
}

if(FALSE == mysql_select_db(DB, $MySqlLinkId))
{
	echo("({ErrCode:2, ErrMsg:'".json_encode(mysql_error($MySqlLinkId))."'})");
	mysql_close($MySqlLinkId);
	exit();
}

if(FALSE == mysql_query("INSERT INTO Account(Name, Password) VALUES('".mysql_real_escape_string($user)."', '".mysql_real_escape_string($pwd)."')", $MySqlLinkId))
{
	echo("({ErrCode:3, ErrMsg:'".json_encode(mysql_error($MySqlLinkId))."'})");
	mysql_close($MySqlLinkId);
	exit();
}
else
{
	echo("({ErrCode:0, ErrMsg:''})");
	mysql_close($MySqlLinkId);
	exit();
}

?>